<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">知识分类权限管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>系统管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">知识分类权限管理</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">


		<div class="row" >
			<div class="col-lg-4">
	            <div class="panel" style="height: 540px; overflow: auto;">
	                <div class="panel-heading">部门列表</div>
	                <div class="panel-body" style="padding-top: 5%;" >
	                	<ul id="tree" class="ztree" style="width:270px"; overflow:auto;"></ul>
	                </div>
	            </div>
	        </div>
	        <div class="col-lg-8">
	            <div class="panel" style="height: 540px; overflow: auto;">
	                <div class="panel-heading">知识库
						</div>
	                <div class="panel-body" >
                        <div class="panel-body">
                           <div id="repositorys">
                           		<span class='subtitle' style="color: #CCC;" >数据为空！请选择部门...</span>
                           </div>
                        </div>
	                </div>
	            </div>
	        </div>
		</div>
	<!--END CONTENT-->
	</div>
</div>
<div id="box1" style="display: none; ">

</div>
<?} ?>
<script>
 var ztreeId ;

function getZTreeId(){
		return ztreeId
	}
$(function() {
		initTree();
		
	});
	function initTree() {
		$.ajax({
			type : "post",
			data : {},
			url : "knowledgeEditDataQueryDepartment.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {
			},
			success : drawTree,
		});
	}

	function drawTree(data) {
	//alert(JSON.stringify(data));
		var setting = {
			view : {
				dblClickExpand : false,
			},
			data : {
				simpleData : {
					enable : true,
				}
			},
			check : {
				enable : false
			},
			callback : {
				onClick : onClick
			},
		};
		var zNodes = eval(data);
		$.fn.zTree.init($("#tree"), setting, zNodes).expandAll(true);
		zTree = $.fn.zTree.getZTreeObj("tree");
		zTree.expandNode(zTree.getNodes()[0], true);

	}
	
	function onClick(e, treeId, treeNode) {
		ztreeId = treeNode.id;	
		addRepository();
	}
	
	function addRepository(){
		$.ajax({
			type : "post",
			url : "knowledgeEditDataAddJurisdictionDomain.do",
			dataType : "json",
			data :{
				"id" : ztreeId
			},
			beforeSend : function(XMLHttpRequest) {
			},
			success : function(data){
				//alert(JSON.stringify(data));
				var str = "";
				$("#repositorys").html("");
				for ( var i = 0; i < data.length; i++) {
					str += "<input class='btn btn-blue btn-square' style='margin-top: 10px;margin-left:6px;' onclick='querybutton("+data[i].id+")' type='button' value="+data[i].nameZh+" />"
				}
					str += "<input style='margin-top: 10px;margin-left:6px;' class='btn btn-blue btn-square' onclick='listbox()' type='button' value='+' />";
				$("#repositorys").append(str);
			},
		});
	}
	
	
	function listbox(){
		layer.open({
			type : 2,
			area : [ '888px', '600px' ],
			scrollbar: false,
		    shadeClose: true,
			fix : false, //不固定
			title : '知识库',
			btn : [ '保存 ', '关闭' ],
			skin : 'layui-layer-rim', //加上边框
			content : ["knowledge-edit-data-addRepository.html",'no'],
			yes : function(index, layer) {
				 var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				 iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	}
	
</script>